﻿using Microsoft.Extensions.DependencyInjection;
using StormCoding.DIExtensions.Filter;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace StormCoding.DIExtensions.Selector
{
    public class ImplementationTypeSelector : IImplementationTypeSelector, ISelector
    {
        private ISelector Inner { get; }
        private IEnumerable<Type> Types { get; }

        private IList<ISelector> Selectors { get; } = new List<ISelector>();
        public ImplementationTypeSelector(ISelector inner, IEnumerable<Type> types) {

            this.Inner = inner;
            this.Types = types;
        }

        public IServiceTypeSelector AddPublicNonAbstractClasses(Action<IImplementationTypeFilter> action)
        {
            var classes = Types.Where(x => x.IsPublicNonAbstractClass()).ToList();
            var filer = new ImplementationTypeFilter(classes);
            action(filer);
            var selector = new ServiceTypeSelector(this,Types);
            return selector;
        }

        public void Register(IServiceCollection services, RegistrationBehavior behavior)
        {
            throw new NotImplementedException();
        }
    }
}
